package com.ruoyi.develop.goodsSampleApply.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.develop.goodsSampleApply.domain.GoodsSampleApply;
import com.ruoyi.develop.goodsSampleApply.service.IGoodsSampleApplyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 质检样品申请Controller
 * @author qh
 * @date 2025-02-15
 */
@RestController
@RequestMapping("/goodsSampleApply/goodsSampleApply")
public class GoodsSampleApplyController extends BaseController {
    @Autowired
    private IGoodsSampleApplyService goodsSampleApplyService;

    /**
     * 查询质检样品申请列表
     */
    @PreAuthorize("@ss.hasPermi('develop:GoodsSampleApply:query')")
    @GetMapping("/list")
    public TableDataInfo list(GoodsSampleApply entity) {
        startPage();
        List<GoodsSampleApply> list = goodsSampleApplyService.selectList(entity);
        return getDataTable(list);
    }

    /**
     * 导出质检样品申请列表
     */
    @PreAuthorize("@ss.hasPermi('develop:GoodsSampleApply:export')")
    @Log(title = "质检样品申请", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GoodsSampleApply entity) {
        List<GoodsSampleApply> list = goodsSampleApplyService.selectList(entity);
        ExcelUtil<GoodsSampleApply> util = new ExcelUtil<GoodsSampleApply>(GoodsSampleApply. class);
        util.exportExcel(response, list, "质检样品申请数据");
    }

    /**
     * 获取质检样品申请详细信息
     */
    @PreAuthorize("@ss.hasPermi('develop:GoodsSampleApply:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(goodsSampleApplyService.selectById(id));
    }

    /**
     * 新增质检样品申请
     */
    @PreAuthorize("@ss.hasPermi('develop:GoodsSampleApply:add')")
    @Log(title = "质检样品申请", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody GoodsSampleApply entity) {
        return toAjax(goodsSampleApplyService.insert(entity));
    }

    /**
     * 修改质检样品申请
     */
    @PreAuthorize("@ss.hasPermi('develop:GoodsSampleApply:edit')")
    @Log(title = "质检样品申请", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody GoodsSampleApply entity) {
        return toAjax(goodsSampleApplyService.update(entity));
    }


    /**
     * 审核质检样品申请
     */
    @PreAuthorize("@ss.hasPermi('develop:GoodsSampleApply:edit')")
    @Log(title = "审核质检样品申请", businessType = BusinessType.UPDATE)
    @PutMapping("/assess")
    public AjaxResult assess(@RequestBody GoodsSampleApply entity) {
        return toAjax(goodsSampleApplyService.assess(entity));
    }




    /**
     * 删除质检样品申请
     */
    @PreAuthorize("@ss.hasPermi('develop:GoodsSampleApply:remove')")
    @Log(title = "质检样品申请", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(goodsSampleApplyService.deleteByIds(ids));
    }
}
